package com.xindaoapp.happypet;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.xindaoapp.happypet.activity.ActivityNearFriend;
import com.xindaoapp.happypet.ui.MyRecordActivity;
import com.xindaoapp.happypet.ui.NearByActivity;
import com.xindaoapp.happypet.utils.CommonParameter.UserState;

public class FoundFragement extends Fragment implements OnClickListener {
    private RelativeLayout found_nearby;
    private RelativeLayout found_integral;// 积分商城
    private RelativeLayout found_friend;
    private Context mContext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_found, null);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        initView();
        mContext = getActivity();
        super.onActivityCreated(savedInstanceState);
    }

    private void initView() {

        // DrawerLayout mDrawerLayout = (DrawerLayout)
        // getActivity().findViewById(R.id.drawer_layout);
        // mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);


        found_nearby = (RelativeLayout) getView().findViewById(R.id.found_nearby);
        found_integral = (RelativeLayout) getView().findViewById(R.id.found_integral);
        found_friend = (RelativeLayout) getView().findViewById(R.id.found_friend);

        found_nearby.setOnClickListener(this);
        found_integral.setOnClickListener(this);
        found_friend.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.found_nearby:
                Intent intent = new Intent(mContext, NearByActivity.class);
                startActivity(intent);
                break;
            case R.id.found_friend:
                Intent intent1 = new Intent(mContext, ActivityNearFriend.class);
                startActivity(intent1);
                break;
            case R.id.found_integral:
                if (UserState.isLogged(getActivity())) {
                    // Intent intent2 = new Intent(mContext, MainActivity.class);
                    // intent2.putExtra(Constants.KEY_SKIP_CLASS_NAME,
                    // IntegralFragment.class.getCanonicalName());
                    // mContext.startActivity(intent2);
                    Intent intent2 = new Intent(mContext, MyRecordActivity.class);
                    mContext.startActivity(intent2);
                }
                break;
            default:
                break;
        }
    }
}
